
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.hello = {}));
})(this, (function (exports) { 'use strict';

    /******************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
    /* global Reflect, Promise, SuppressedError, Symbol */


    function __spreadArray(to, from, pack) {
        if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
            if (ar || !(i in from)) {
                if (!ar) ar = Array.prototype.slice.call(from, 0, i);
                ar[i] = from[i];
            }
        }
        return to.concat(ar || Array.prototype.slice.call(from));
    }

    typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
        var e = new Error(message);
        return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
    };

    function debounce(fun, delay, isImmediate) {
        if (delay === void 0) { delay = 500; }
        if (isImmediate === void 0) { isImmediate = true; }
        var timer = null; // 定时器
        var immediateTimer = null; // 继续首次触发的定时器
        var _isImmediate = isImmediate; // 第一次触发是否立即
        // 返回的函数类型是 FunctionType，即接收任意参数并无返回值的函数
        return function () {
            var _this = this;
            var rest = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                rest[_i] = arguments[_i];
            }
            timer && clearTimeout(timer);
            immediateTimer && clearTimeout(immediateTimer);
            if (_isImmediate) {
                fun.call.apply(fun, __spreadArray([this], rest, false));
                _isImmediate = false;
                timer = null;
                immediateTimer = setTimeout(function () {
                    _isImmediate = isImmediate;
                    immediateTimer = null;
                }, delay);
            }
            else {
                timer = setTimeout(function () {
                    fun.call.apply(fun, __spreadArray([_this], rest, false));
                    _isImmediate = isImmediate;
                    timer = null;
                    immediateTimer = null;
                }, delay);
            }
        };
    }
    function throttle(fun, delay, immediate) {
        if (delay === void 0) { delay = 500; }
        if (immediate === void 0) { immediate = true; }
        var previousTimeStamp = 0; // 上一次点击的时间戳
        var timer = null; // 定时器
        return function () {
            var _this = this;
            var rest = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                rest[_i] = arguments[_i];
            }
            if (immediate) {
                var nowTimeStamp = +new Date(); // 获取当前点击的时间戳
                if (nowTimeStamp - previousTimeStamp > delay) {
                    fun.call.apply(fun, __spreadArray([this], rest, false));
                    previousTimeStamp = nowTimeStamp;
                }
            }
            else {
                if (!timer) {
                    timer = setTimeout(function () {
                        fun.call.apply(fun, __spreadArray([_this], rest, false));
                        timer = null;
                    }, delay);
                }
            }
        };
    }

    exports.debounce = debounce;
    exports.throttle = throttle;

}));
